﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using BussinesLayer.Services;
using DataAccess.Datatypes;

namespace Services.Controllers
{
    public class SiteController : ApiController
    {

        // GET api/Site
        public IEnumerable<Site> Get()
        {
            SiteServices bl = new SiteServices();
            return bl.GetSites();
        }

        //// GET api/Site/5
        //public Site GetSite(int id)
        //{
        //    Site site = db.SiteSet.Find(id);
        //    if (site == null)
        //    {
        //        throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
        //    }

        //    return site;
        //}

        //// PUT api/Site/5
        //public HttpResponseMessage PutSite(int id, Site site)
        //{
        //    if (!ModelState.IsValid)
        //    {
        //        return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
        //    }

        //    if (id != site.Id)
        //    {
        //        return Request.CreateResponse(HttpStatusCode.BadRequest);
        //    }

        //    db.Entry(site).State = EntityState.Modified;

        //    try
        //    {
        //        db.SaveChanges();
        //    }
        //    catch (DbUpdateConcurrencyException ex)
        //    {
        //        return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
        //    }

        //    return Request.CreateResponse(HttpStatusCode.OK);
        //}

        //// POST api/Site
        //public HttpResponseMessage PostSite(Site site)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.SiteSet.Add(site);
        //        db.SaveChanges();

        //        HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, site);
        //        response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = site.Id }));
        //        return response;
        //    }
        //    else
        //    {
        //        return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
        //    }
        //}

        // DELETE api/Site/5
        //public HttpResponseMessage DeleteSite(int id)
        //{
        //    Site site = db.SiteSet.Find(id);
        //    if (site == null)
        //    {
        //        return Request.CreateResponse(HttpStatusCode.NotFound);
        //    }

        //    db.SiteSet.Remove(site);

        //    try
        //    {
        //        db.SaveChanges();
        //    }
        //    catch (DbUpdateConcurrencyException ex)
        //    {
        //        return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
        //    }

        //    return Request.CreateResponse(HttpStatusCode.OK, site);
        //}
    }
}